//
//  YWColorChooseController.m
//  YWPhotoEditMaster
//
//  Created by jun peng on 2023/8/3.
//

#import "YWColorChooseController.h"
#import "UIImage+GetColor.h"

@interface YWColorChooseController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation YWColorChooseController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewClick:)];
    [self.imageView addGestureRecognizer:tap];
}

-(void)imageViewClick:(UITapGestureRecognizer *)gester{
    
    UIImageView *imageView = (UIImageView *)gester.view;
    CGPoint point = [gester locationInView:imageView];

    UIColor *color = [imageView.image pixelColorAtLocation:point];
    
    if(self.didSelectColorBlock){
        self.didSelectColorBlock(color);
    }
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
